package zjs.dc.controller;

import org.apache.spark.sql.SparkSession;

/**
 * @Class:
 * @Author: kongcb
 * @Description: 工商统计:t_manage_count每次全量更新
 * @Date: 2021/12/15 9:21
 */
public class TManageCount {
    public static void main(String[] args) {
        SparkSession spark = SparkSession.builder().appName("t_manage_count").enableHiveSupport().getOrCreate();
        spark.sparkContext().setLogLevel("ERROR");
        //企业工商数据t_eci_company
        spark.sql("select company_id,company_name from a_dc_ep_ods.t_eci_company").createOrReplaceTempView("eci_company");
        //企业工商数据t_eci_partner
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_licens group by company_id").createOrReplaceTempView("eci_licens");
        //企业工商数据t_eci_employee
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_eci_spotcheck group by company_id").createOrReplaceTempView("eci_spotcheck");
        //企业工商数据t_eci_branch
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_tender group by company_id").createOrReplaceTempView("tender");
        //企业工商数据t_eci_change
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_import_export group by company_id").createOrReplaceTempView("import_export");
        //企业工商数据t_investinfo
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_taxcredit group by company_id").createOrReplaceTempView("taxcredit");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_recruitinfo group by company_id").createOrReplaceTempView("recruitinfo");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_newsinfo group by company_id").createOrReplaceTempView("newsinfo");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_product group by company_id").createOrReplaceTempView("product");
        //企业工商数据t_annual_report
        spark.sql("select company_id,count(1) cn from a_dc_ep_dwi.t_financing group by company_id").createOrReplaceTempView("financing");

        spark.sql("insert overwrite table a_dc_ep_incr.t_manage_count select a.company_id,a.company_name,b.cn,c.cn,d.cn,e.cn,'','','','',f.cn,g.cn,'',h.cn,i.cn,j.cn from eci_company a " +
                "left join eci_licens b on a.company_id = b.company_id " +
                "left join eci_spotcheck c on a.company_id = c.company_id " +
                "left join tender d on a.company_id = d.company_id " +
                "left join import_export e on a.company_id = e.company_id " +
                "left join taxcredit f on a.company_id = f.company_id " +
                "left join recruitinfo g on a.company_id = g.company_id " +
                "left join newsinfo h on a.company_id = h.company_id " +
                "left join product i on a.company_id = i.company_id " +
                "left join financing j on a.company_id = j.company_id");
        spark.stop();
    }
}
